import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';

@Component({
  selector: 'app-webclient',
  templateUrl: './webclient.component.html',
  styleUrls: ['./webclient.component.less']
})
export class WebclientComponent implements OnInit {
  value = '';
  request = '';
  response = '';

  constructor(private http: HttpClient) { }

  ngOnInit(): void {
  }

  send(): void {
    try {
      const url = 'http://' + this.value;
      this.http.post(url, this.request).toPromise().then(resp => {
        console.log(resp);
        this.response = JSON.stringify(resp);
      }).catch(err => {
        this.response = JSON.stringify(err);
        console.log(err);
      });
      // console.log(result);
    } catch (error) {
      console.error(error);
    }
  }
}
